var express=require("express");
var app=express();

var movies=[
    {name:"摔跤吧爸爸",year:"2017",num:5},
    {name:"逆时营救",year:"2017",num:5},
    {name:"解救吾先生",year:"2015",num:5},
    {name:"喜欢你",year:"2017",num:3},
    {name:"速度与激情8",year:"2017",num:5},
]

app.use(express.static("static"));

app.get("/",function(req,res){
    res.send("欢迎一起看电影");
})

app.get("/movies",function(req,res){
    res.send(movies);
})
app.get("/add",function(req,res){
    var index=req.query.index;
    if(movies[index].num<=4){
    movies[index].num=movies[index].num+1;
}
    res.send({status:0})
})

app.get("/min",function(req,res){
    var index=req.query.index;
    if(movies[index].num>0){
    movies[index].num=movies[index].num-1;
}
    res.send({status:0})
})
app.get("/del",function(req,res){
    var index=req.query.index;
    movies.splice(index,1);
    res.send({status:0});
})
app.listen(5656);